home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 25
/
AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso
/
PublicDomain
/
Anwendungen
/
UpDateCopy
/
Source
/
UpDateCopy.e
Wrap
Text File
|
1998-07-04
|
36KB
|
1,147 lines
/*
** ToDo: 160 may be used as space (32)
*/
/* UpDateCopy.e
** Copies multiple files/directories to one destination.
** Not existing directories are created.
** Already existing files are only replaced by newer ones
** (UpDateCopy first checks for versions-string and then
** for dates).
**
** $VER: UpDateCopy.e 2.0 (04.07.98)
**
** This program is Cardware. If you use it you should send an Email to
** the author. Also small presents are very welcome.
** You may use this sourcefile or parts of it freely in your programs.
** But please do not spread a modified version under this name (UpDateCopy).
** For Bugreports, ideas or anything else send a Email to:
** ss37@inf.tu-dresden.de
**
** Sven Steiniger, 1996-98
**
** Fold-start: ->// ""
** Fold-stop: ->\\
**
** History:
** 2.0 : - FIXED: archive bit was modified in TESTMODE
** - slightly optimized copyfile()
** - FIXED: error during writing the last part of an file may be not recognized
** 1.9 : - added PATTERN option to set the pattern used for recursiv scanning
** 1.8 : - validateFilename() is much faster now
** - FIXED: sometimes forgot to unlock files
** - now works with strange patterns, eg. "Text (deutsch)/#?"
** 1.7 : - UDC failed if it processes directories containing characters
** declared as wildcards (eg. "(" or "?").
** Note: standard "C:" commands fail here!! Just try
** 'copy "WBStartup (Enabled)" ram:'
** 1.6 : - changed getVersion() to recognize different version strings
** (eg. 'Test v1.0', 'Test 1', 'Test 2.')
** 1.5 : - anchor structure was not longword aligned
** : - added lha-compatible date compare mode
** 1.4 : - FIXED: directories may be created, even in testmode
** : - FIXED: protection bits may be modified in testmode
** 1.3 : - the file-io buffer is now allocated once at start
** . - cleaned up
** 1.2 : - fixed small bug in getVersion()
** 1.1 : - uses now asyncio.library for fantastic speed
** 1.00: - implemented SAB, CAB options
** 0.54: - implemented NOASK-option
** 0.53: - now user is asked on errors. Doesn't works perfect but I don't now
** how to implement it properly without adding to much extra code.
** 0.52: - improved SMARTINFO-option
** 0.51: - removed bug of version-scan-routines
** 0.50: - added FAST-option
** 0.49: - added SMARTINFO option
** - added wildcard-check. Now you can also use '*' as wildcard and
** you can also pass devices as sources (eq. ram:)
** 0.48: - used exthelp-feature OF ReadArgs()
** - no longer needs 'c:copy'-command. Implemented an own routine.
** 0.47: - file was not closed before SetProtection()/SetFileDate()
** 0.46: - added PAPF-option -> archive protection flag is not changed
** 0.45: - added CLONE-option -> Datestamp is copied
** 0.44: - removed a unnecessary module. Saves 1K of executable size!
** - removed unnecessary ExamineFH()
** - now file gets only examined if really necessary
** - optimized a bit
** - FIXED: TESTMODE was buggy -> Directories were still created.
** 0.43: - add new option TESTMODE; dont copy/replace files
** 0.42: - add new option NODATECHECK; dont compare datestamps
** 0.41: - replaced all reads/writes by fread/fwrite
** 0.40: - first public release
*/
OPT OSVERSION=37
OPT PREPROCESS
OPT REG=5
MODULE 'dos/dos','dos/dosasl','dos/dostags','dos/rdargs','dos/stdio',
'asyncio','libraries/asyncio'
MODULE 'sven/anchorPath',
'sven/eAddPart'
RAISE "MEM" IF String()=NIL,
"^C" IF CtrlC()=TRUE,
"copy" IF FileLength()=-1,
"MEM" IF AllocDosObject()=NIL,
"fatt" IF SetProtection()=DOSFALSE,
"fatt" IF SetComment()=DOSFALSE,
"fatt" IF SetFileDate()=DOSFALSE
#define OpenAsyncRead(filename) OpenAsync(filename,MODE_READ,ASYNCBUFFER)
#define OpenAsyncWrite(filename) OpenAsync(filename,MODE_WRITE,ASYNCBUFFER)
#define CloseAsyncRead(fh) CloseAsync(fh)
#define CloseAsyncWrite(fh,exceptid) IF fh THEN IF CloseAsync(fh)<0 THEN Raise(exceptid)
#define SafeReadAsync(fh,buffer,length,exceptid) IF ReadAsync(fh,buffer,length)<>(length) THEN Raise(exceptid)
#define SafeWriteAsync(fh,buffer,length,exceptid) IF WriteAsync(fh,buffer,length)<>(length) THEN Raise(exceptid)
CONST MAXPATH=256, -> Maximum path length
SPACEADD=3, -> Number of spaces per indent
SAFETYBYTES=150, -> Maximum length of versionstring
BIGFILEMEM=16384 -> Files bigger than that are not read
-> completly into memory
CONST PATHLENGTH=MAXPATH-1,
BIGFILESIZE=BIGFILEMEM-SAFETYBYTES,
MAXPATH2=MAXPATH*2
CONST ASYNCBUFFER=BIGFILESIZE*2,
IOBUFFERSIZE=BIGFILEMEM+8 -> size of io-buffer (+8 'coz getVersion()
-> may read 4 additional bytes)
ENUM PDIR_Error,
PDIR_Skipped,
PDIR_Created
ENUM PFILE_Error,
PFILE_Skipped,
PFILE_Copied,
PFILE_Replaced
ENUM ASKUSER_Abort,
ASKUSER_Retry,
ASKUSER_Skip
DEF frompath[MAXPATH]:STRING, -> actual sourcepath
fromlist:PTR TO LONG, -> pointer to array of sourcestrings
topath[MAXPATH]:STRING, -> destinationpath
doinfo, -> should we write informations ?
recursiv, -> scan recursively through subdirectories ?
ignoreprotection, -> clear delete-protection ?
checkversion, -> compare version-strings ?
checkdates, -> compare datestamps ?
testmode, -> test modus ? (do not copy/replace files)
clone, -> copy datestamp ?
cleararchivebit, -> clear archivebit OF copied file
smartinfo, -> only display copied/replaced files
fastdisplay, -> no linefeed
interaction, -> ask user on errors
setarchivebit, -> set Archive bit
checkarchivebit, -> check Archive bit
lousydatestamp, -> lha compatible datestamp compare
subpattern[MAXPATH]:STRING, -> pattern used to scan subdirectories/devices
dirlock=NIL -> PTR TO lock-structure OF destination path
DEF buffer=NIL:PTR TO CHAR -> the global buffer used for all file-io.
-> Contains IOBUFFERSIZE Bytes
PROC main() HANDLE
->// "main()"
DEF rdargs=NIL,
myargs:PTR TO LONG,
myrdargs=NIL:PTR TO rdargs,
exthelp[1000]:STRING
asynciobase:=OpenLibrary('asyncio.library',39)
IF asynciobase=NIL THEN Raise("asio")
/* Initialize argument-array */
myargs:=[
NIL, -> fromlist
NIL, -> destination path
FALSE, -> ~showinfo
FALSE, -> scan recursiv throuhg subdirectories
FALSE, -> ignore protectionbits
FALSE, -> deep scan
FALSE, -> ~compare datestamps
FALSE, -> testmode
FALSE, -> clone
FALSE, -> preserve archive protection flag
FALSE, -> smartinfo
FALSE, -> fastdisplay
FALSE, -> interaction
FALSE, -> set Archivebit
FALSE, -> check Archivbit
FALSE, -> precise datestamp
'#?' -> subpattern
]:LONG
myrdargs:=AllocDosObject(DOS_RDARGS,NIL)
StrCopy(exthelp, '\n'+
' UpDateCopy v2.0\n'+
' -----------------\n'+
' Copy files and directories.\n'+
' Not existing directories are created and\n'+
' already existing files are only replaced\n'+
' by newer ones. Allows pattern-matching and\n'+
' multiple sourcedirectories/files.\n\n'+
'Sven Steiniger, 1996-98\n'
)
StrAdd(exthelp, '\n'+
' FROM - source directory/file(s)\n'+
' TO - dest